package payment

import "fmt"

type WechatPay struct {
	Config
	MchCertificate string //微信特有字段
}

// 构造函数
func NewWechatPay(config Config, cert string) *WechatPay {
	return &WechatPay{
		Config:         config,
		MchCertificate: cert,
	}
}
func (w *WechatPay) Pay(amount float64) (string, error) {
	//模拟签名生成
	sign := fmt.Sprintf("%s|%s|%.2f", w.MerchantID, w.SecretKey, amount)
	return fmt.Sprintf("微信支付成功[签名。%s][回调:%s]",
		sign[:3]+"***", w.NotifyURL), nil
}

func (w *WechatPay) Refund(orderID string) (string, error) {
	//模拟证书验证
	return fmt.Sprintf("微信退款成功[证书 :%s][订单：%s]",
		w.MchCertificate[:3]+"***", orderID), nil
}
